package com.nbjtjc.safe.api.danger;

import com.nbjtjc.common.validator.ValidatorUtils;
import com.nbjtjc.common.validator.group.UpdateGroup;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.danger.DangerReformReply;
import com.nbjtjc.safe.service.danger.DangerReformReplyService;
import com.nbjtjc.safe.service.danger.IndexService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.groups.Default;

/**
 * @auther guqianbin
 * @date 2018/6/23 11:18
 * 隐患整改回执
 **/
@RestController
@RequestMapping("/danger/reformReply")
@CrossOrigin("*")
public class DangerReformReplyController {
    private static Logger logger= LoggerFactory.getLogger(DangerReformReplyController.class);

    @Autowired
    private DangerReformReplyService dangerReformReplyService;

    @RequestMapping(value = "/find",method = {RequestMethod.POST,RequestMethod.GET})
    public Result find(DangerReformReply dangerReformReply){

        Result result=new Result();
        result.setData(dangerReformReplyService.find(dangerReformReply));
        return result;
    }
    @PostMapping("/add")
    public Result add(DangerReformReply dangerReformReply){
        ValidatorUtils.validateEntity(dangerReformReply);
        Result result=new Result();
        result.setData(dangerReformReplyService.add(dangerReformReply));
        return result;
    }


    @PostMapping("/update")
    public Result update(DangerReformReply dangerReformReply){
        ValidatorUtils.validateEntity(dangerReformReply,UpdateGroup.class,Default.class);
        Result result=new Result();
        result.setData(dangerReformReplyService.update(dangerReformReply));
        return result;
    }
}
